import VueRouter from "vue-router";
import About from "../pages/About"
import Home from "../pages/Home"
import News from "../pages/News"
import Message from "../pages/Message"
import Detail from "../pages/Detail"
export default new VueRouter({
    routes:[
        {
            path:"/about",
            component:About,
         
        }, 
        {
            path:"/home",
            component:Home,
            children:[
                {
                    path:"news",
                    component:News
                },
                {
                    path:"message",
                    component:Message,
                    children:[
                        {
                            name:"detail",
                            // path:"detail/:id/:title",
                            path:"detail",
                            component:Detail,

                            //第一种写法  对象传递
                            // props:{a:1,b:2}
                            //第二种写法  当为true时,会把param的参数以props形式传递过去
                            // props:true

                            //第三种 函数
                            props($route){
                                // return {
                                //     id:$route.params.id,
                                //     title:$route.params.title
                                // }
                                return {
                                    id:$route.query.id,
                                    title:$route.query.title
                                }
                            }
                        }
                    ]
                }
            ]
        },
    ]
})